﻿using PAP.Application.Core;
using PAP.Application.Dtos.UserAccount.Commands;
using PAP.Domain.UserAccount.Entities;
using PAP.Domain.UserAccount.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PAP.Application.CommandHandlers.UserAccount
{
    public class RegisterUserCommandHandler : CommandHandler<RegisterUserCommand>
    {
        #region "Fields"
        private readonly IUserRepository _userRepository;
        #endregion

        #region "Constructors"
        public RegisterUserCommandHandler(IUnitOfWork unitOfWork, IUserRepository userRepository)
            : base(unitOfWork)
        {
            this._userRepository = userRepository;
        }
        #endregion

        #region "Methods"
        protected override void Execute(RegisterUserCommand command)
        {
            var hashedPassword = string.Empty;
            var user = new User(command.Login, hashedPassword, command.Firstname, command.Lastname);
            this._userRepository.Add(user);
        }
        #endregion
    }
}
